<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    {include file="layout:_meta" /}
    <title>添加管理员 - 管理员管理</title>
</head>
<body>
<article class="cl pd-20">
    <form class="form form-horizontal" id="form-admin">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" v-model="model.username">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" v-model="model.password">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" v-model="model.repassword">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input value="1" type="radio" id="sex-1" v-model="model.status">
                    <label for="sex-1">启用</label>
                </div>
                <div class="radio-box">
                    <input value="0" type="radio" id="sex-2"  v-model="model.status">
                    <label for="sex-2">停用</label>
                </div>
            </div>
        </div>
        
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" v-on:click="doSubmit()" value="提交">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
{include file="layout:_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var model = {
        status:1,
        role:0
    };

    var store_model = new Vue({
        el: "#form-admin",
        data: {
            model:model,
            roles: []
        },
        methods: {
            doSubmit: function() {
                $.ajax({
                    type:'post',
                    data:this.model,
                    url:"{:url('admin/add')}",
                    cache: false,
                    dataType:'json',
                    success:function(data){
                        if(data.status==true){
                            layer.msg(data.message,function () {
                                parent.location.href="{:url('admin/index')}";
                                //layer_close();
                            })
                        }else {
                            layer.msg(data.message);
                        }
                    }
                });
            }
        }
    });

    //菜单模块
    util.get("{:url('admin/add')}",function (data) {
        store_model.roles = data;
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>